ci: add pylint presubmit on golden files (closes #16393)#16808
ci: add pylint presubmit on golden files (closes #16393)#16808parthea merged 3 commits intogoogleapis:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a .pylintrc configuration file for golden client libraries to manage Pylint checks during CI. Feedback indicates that disabling no-name-in-module and import-error might conflict with the objective of catching broken imports, suggesting that adjusting the CI environment's PYTHONPATH could be a better alternative. Furthermore, some disabled checks are redundant as they are not error-level messages and the CI is configured to run with --errors-only.
| no-name-in-module, | ||
| no-member, | ||
| import-error, | ||
| relative-beyond-top-level, | ||
| cyclic-import |
There was a problem hiding this comment.
The disable list includes no-name-in-module (E0611) and import-error (E0401), which appears to conflict with the stated goal of catching "broken imports." These checks are the primary way Pylint identifies missing modules or missing attributes within a module. If they are disabled because they "consistently misfire," it might be worth investigating if the CI environment's PYTHONPATH can be configured to include the generated packages instead of disabling the checks globally.
Additionally, relative-beyond-top-level (W0402) and cyclic-import (R0401) are redundant in this list because they are not Error-level messages, and the CI is configured to run with --errors-only.
|
Hi @MukundaKatta, Thanks for opening a PR! If you're interested in continuing with this contribution, please review the presubmit failure in https://github.com/googleapis/google-cloud-python/actions/runs/24968202788/job/73295304241?pr=16808 One potential solution is to silence pylint for the functions which are not implemented. The change would need to be made in the jinja template below: Once the template is changed, follow the instructions below to regenerate the golden files: |
The generator emits __hash__ stubs as 'return NotImplementedError(...)' which fails pylint's invalid-hash-returned check. Disable the check in the goldens .pylintrc until the generator template is updated to use 'raise' (tracking googleapis#16393).
|
@parthea pushed a fix: added @gemini-code-assist re your point on |
|
Thanks for the update, @MukundaKatta. Adding |
Why
Issue #16393 asks for a
pylintpresubmit check on the GAPIC golden client libraries so generator regressions are caught at PR time.flake8andruffalready run on these goldens, but they do not catch the kinds of issuespylintflagged in the original investigation (undefined names, broken imports, etc.).What
packages/gapic-generator/tests/integration/goldens/.pylintrcscoped to the goldens. Conservative bar to start:pylint --errors-onlyis used in CI, and the.pylintrcdisables the small set of error-class checks that consistently misfire on auto-generated GAPIC output (no-name-in-module,no-member,import-error,relative-beyond-top-level,cyclic-import). This catches real bugs without forcing a stylistic cleanup of the existing goldens, which can be tightened later.Pylint goldens (errors only)step in the existinggoldensjob in.github/workflows/gapic-generator-tests.yml. Runs after the existingformat/lint/unitnox sessions, so the heavy setup is amortized. Iterates over the samecredentials eventarc logging redisset.Tested
pathsfilter as the rest ofgapic-generator-tests.yml, so it stays silent on PRs that do not touch the generator.pylint --errors-only --rcfile=.pylintrconly reports E/F categories minus the listed disables, which keeps the signal meaningful and stops the generator from silently regressing on the next refactor.If the maintainers want a different starting bar (e.g. include warnings, or run on more golden packages), happy to adjust.